﻿using NMortgage.UI.ViewModels;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Caliburn.Micro;
using NMortgage.UI.Model;
using Moq;
using NMortgage.UI.Events;
using NMortgage.UI.Tests.Model;

namespace NMortgage.UI.Tests
{
    [TestClass()]
    public class ExtraPaymentViewModelTest : TestBase<ExtraPaymentViewModel>
    {
        [TestInitialize]
        public void Init()
        {
            Subject = new ExtraPaymentViewModel(new EventAggregator());
        }

        [TestMethod()]
        public void ExtraPaymentViewModelConstructorTest()
        {
            IEventAggregator eventAggregator = new EventAggregator();
            ExtraPayment item = new ExtraPayment();
            ExtraPaymentViewModel target = new ExtraPaymentViewModel(eventAggregator, item);
            Assert.IsNotNull(target);
        }

        [TestMethod()]
        public void ExtraPaymentViewModelConstructorTest1()
        {
            IEventAggregator eventAggregator = new EventAggregator();
            ExtraPaymentViewModel target = new ExtraPaymentViewModel(eventAggregator);
            Assert.IsNotNull(target);
        }

        //[TestMethod()]
        //public void CancelTest()
        //{
        //    Subject.Cancel();
        //    Helper.EventAggregator.Verify(x => x.Publish(It.Is<CancelEvent>(c => c.Source.GetType() == typeof(ExtraPaymentViewModel))));
        //}

        //[TestMethod()]
        //public void FinishTest()
        //{
        //    Subject.Finish();
        //    Helper.EventAggregator.Verify(x => x.Publish(It.Is<CancelEvent>(c => c.Source.GetType() == typeof(ExtraPaymentViewModel))));
        //}

        [TestMethod()]
        public void AvailableFrequenciesTest()
        {
            int len = Subject.AvailableFrequencies.Length;
            Assert.IsTrue(len > 0);
        }

        [TestMethod()]
        public void AvailableTypesTest()
        {
            int len = Subject.AvailableTypes.Length;
            Assert.IsTrue(len > 0);
        }

        [TestMethod()]
        public void IsNotRecurringTest()
        {
            Subject.SelectedType = ExtraPaymentType.OneTime;
            var expected = false;
            var actual = Subject.IsRecurring;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsRecurringTest()
        {
            Subject.SelectedType = ExtraPaymentType.Recurring;
            var expected = true;
            var actual = Subject.IsRecurring;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void IsValidTest()
        {
            Subject.PaymentItem = ExtraPaymentTests.GetParameter0();
            var actual = Subject.IsValid;
            Assert.IsTrue(actual);
        }


        [TestMethod()]
        public void IsInValidTest()
        {
            Subject.PaymentItem = ExtraPaymentTests.GetInvalidParameter0();
            var actual = Subject.IsValid;
            Assert.IsFalse(actual);
        }


        [TestMethod()]
        public void PaymentItemTest()
        {
            var expected = ExtraPaymentTests.GetParameter0();

            Subject.PaymentItem = expected;
            var actual = Subject.PaymentItem;

            Assert.AreEqual(expected, actual);
        }
    }
}
